#include <stdio.h>
#include <windows.h>  // 包含 Sleep 函数的头文件
#include <omp.h>

// 假设原func1函数，添加并行指令
void func1(double A[100][100]) {
    #pragma omp parallel for collapse(2)
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            int thread_id = omp_get_thread_num();
            printf("Thread %d is processing A[%d][%d]\n", thread_id, i, j);
            A[i][j] = A[i][j] + 1;
            Sleep(10);  // 休眠 10 毫秒，模拟耗时操作
        }
    }
}

// 假设原func2函数
void func2(double A[100][100]) {
    for (int i1 = 0; i1 < 100; i1 += 4) {
        for (int j1 = 0; j1 < 100; j1 += 16) {
            for (int i2 = i1; i2 < i1 + 4; ++i2) {
                for (int j2 = j1; j2 < (j1 + 16 > 100? 100 : j1 + 16); ++j2) {
                    A[i2][j2] = A[i2][j2] + 1;
                }
            }
        }
    }
}

int main() {
    double A[100][100];
    // 初始化A数组
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            A[i][j] = i * 100 + j;
        }
    }
    // 调用func1函数
    func1(A);
    // 输出A数组部分内容查看结果（可按需修改）
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 5; ++j) {
            printf("%f ", A[i][j]);
        }
        printf("\n");
    }
    return 0;
}